package com.google.code.sms.service.metadata;

import java.io.File;

/**
 *
 * @author scott2ware
 */
public class MetaData {
    
    private Integer mediaElementID;
    private String title;
    private String artist;
    private String albumArtist;
    private String album;
    private String comment;
    private String genre;
    private Integer discNumber;
    private String discSubtitle;
    private Integer trackNumber;
    private Integer bitRate;
    private Integer duration;
    private String coverArtPath;
    private Integer width;
    private Integer height;
    private Integer year;
    private String posterPath;
    private String subtitlesPath;
    private String videoCodec;
    private String audioCodec;
    private Integer audioSampleRate;
    private String audioConfiguration;
    private Float rating;
    private String description;
    private String tagline;
    private String certificate;
    private DirectoryMediaType mediaType;

    public Integer getMediaElementID() {
        return mediaElementID;
    }

    public void setMediaElementID(Integer mediaElementID) {
        this.mediaElementID = mediaElementID;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getArtist() {
        return artist;
    }

    public void setArtist(String artist) {
        this.artist = artist;
    }
    
    public String getAlbumArtist() {
        return albumArtist;
    }

    public void setAlbumArtist(String albumArtist) {
        this.albumArtist = albumArtist;
    }

    public String getAlbum() {
        return album;
    }

    public void setAlbum(String album) {
        this.album = album;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }
    
    public String getGenre() {
        return genre;
    }

    public void setGenre(String genre) {
        this.genre = genre;
    }

    public Integer getDiscNumber() {
        return discNumber;
    }

    public void setDiscNumber(Integer discNumber) {
        this.discNumber = discNumber;
    }
    
    public String getDiscSubtitle() {
        return discSubtitle;
    }

    public void setDiscSubtitle(String discSubtitle) {
        this.discSubtitle = discSubtitle;
    }

    public Integer getTrackNumber() {
        return trackNumber;
    }

    public void setTrackNumber(Integer trackNumber) {
        this.trackNumber = trackNumber;
    }
    
    public Integer getBitRate() {
        return bitRate;
    }

    public void setBitRate(Integer bitRate) {
        this.bitRate = bitRate;
    }

    public Integer getDuration() {
        return duration;
    }
    
    public String getDurationAsString() 
    {        
        if (duration == null) {
            return null;
        }

        StringBuilder result = new StringBuilder(8);

        int seconds = duration;

        int hours = seconds / 3600;
        seconds -= hours * 3600;

        int minutes = seconds / 60;
        seconds -= minutes * 60;

        if (hours > 0) {
            result.append(hours).append(':');
            if (minutes < 10) {
                result.append('0');
            }
        }

        result.append(minutes).append(':');
        if (seconds < 10) {
            result.append('0');
        }
        result.append(seconds);

        return result.toString();
    }

    public void setDuration(Integer duration) {
        this.duration = duration;
    }
    
    public String getCoverArtPath() {
        return coverArtPath;
    }
    
    public File getCoverArtFile()
    {
        if(coverArtPath == null)
        {
            return null;
        }
        
        return new File(coverArtPath);
    }

    public void setCoverArtPath(String coverArtPath) {
        this.coverArtPath = coverArtPath;
    }
    
    public Integer getWidth() {
        return width;
    }

    public void setWidth(Integer width) {
        this.width = width;
    }

    public Integer getHeight() {
        return height;
    }

    public void setHeight(Integer height) {
        this.height = height;
    }
    
    public Integer getYear() 
    {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }
    
    public String getPosterPath() {
        return posterPath;
    }

    public File getPosterFile()
    {
        if(posterPath == null)
        {
            return null;
        }
        
        return new File(posterPath);
    }
    
    public void setPosterPath(String posterPath) {
        this.posterPath = posterPath;
    }
    
    public String getSubtitlesPath() {
        return subtitlesPath;
    }
    
    public File getSubtitlesFile()
    {
        if(subtitlesPath == null)
        {
            return null;
        }
        
        return new File(subtitlesPath);
    }

    public void setSubtitlesPath(String subtitlesPath) {
        this.subtitlesPath = subtitlesPath;
    }
    
    public String getVideoCodec() {
        return videoCodec;
    }

    public void setVideoCodec(String videoCodec) {
        this.videoCodec = videoCodec;
    }
    
    public String getAudioCodec() {
        return audioCodec;
    }

    public void setAudioCodec(String audioCodec) {
        this.audioCodec = audioCodec;
    }
    
    public Integer getAudioSampleRate() {
        return audioSampleRate;
    }

    public void setAudioSampleRate(Integer audioSampleRate) {
        this.audioSampleRate = audioSampleRate;
    }
    
    public String getAudioConfiguration() {
        return audioConfiguration;
    }

    public void setAudioConfiguration(String audioConfiguration) {
        this.audioConfiguration = audioConfiguration;
    }
    
    public Float getRating() {
        return rating;
    }

    public void setRating(Float rating) {
        this.rating = rating;
    }
    
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
    
    public String getTagline() {
        return tagline;
    }

    public void setTagline(String tagline) {
        this.tagline = tagline;
    }
    
    public String getCertificate() {
        return certificate;
    }

    public void setCertificate(String certificate) {
        this.certificate = certificate;
    }
    
    public DirectoryMediaType getDirectoryMediaType() {
        return mediaType;
    }

    public void setDirectoryMediaType(DirectoryMediaType mediaType) {
        this.mediaType = mediaType;
    }
    
    public boolean isAudioDirectory()
    {
        return getDirectoryMediaType() == DirectoryMediaType.AUDIO;
    }
    
    public boolean isVideoDirectory()
    {
        return getDirectoryMediaType() == DirectoryMediaType.VIDEO;
    }
    
    public boolean isMixedDirectory()
    {
        return getDirectoryMediaType() == DirectoryMediaType.MIXED;
    }
    
    public static enum DirectoryMediaType {
        AUDIO,
        VIDEO,
        MIXED,
        NONE
    }
}
